"""
这个程序用以确认构词码（gouci.txt）中的字，
足够复盖郑码6.6（zm6_6.txt）中的字
并且生成郑码6.6需要的构词码文件（gouci6_6.txt）。
"""


def getwords(filename):
    s = set()
    f = open(filename)
    for line in f:
        c, m = line.split()
        if len(c) == 1:
            s.add(c)
            # print(c)
    f.close()
    return s


if __name__ == "__main__":
    fromgouci = getwords("gouci.txt")
    fromzm6_6 = getwords("zm6_6.txt")
    print(len(fromgouci))
    print(len(fromzm6_6))
    print(fromzm6_6 - fromgouci)

    rf = open("gouci.txt")
    wf = open("gouci6_6.txt", "w")
    for line in rf:
        c, m = line.split()
        if c not in fromzm6_6:
            continue
        wf.write("{}\t{}\n".format(c, m))
    wf.close()
    rf.close()
